﻿Imports System.Windows.Threading

Public Class Popup
    Dim Timer1 As New DispatcherTimer
    Private Sub Window_MouseLeftButtonDown_1(sender As Object, e As MouseButtonEventArgs)
        Me.DragMove()
    End Sub

    Sub MeMove(Optional a As Byte = 0)
        With SystemParameters.WorkArea
            Select Case a
                Case 0
                    Me.Left = .Left
                    Me.Top = .Bottom - Me.Height
                Case 1
                    Me.Left = .Left
                    Me.Top = .Top
                Case 2
                    Me.Left = .Right - Me.Width
                    Me.Top = .Top
                Case 3
                    Me.Left = .Right - Me.Width
                    Me.Top = .Bottom - Me.Height
            End Select
            Me.Show()
        End With
    End Sub
    Private Sub Window_StateChanged_1(sender As Object, e As EventArgs)
        If Me.WindowState <> Windows.WindowState.Normal Then Me.WindowState = Windows.WindowState.Normal
    End Sub

    Private Sub Window_Loaded_1(sender As Object, e As RoutedEventArgs)
        MeMove(2)
        Timer1.Interval = New TimeSpan(0, 0, 0, 1)

        Timer1.Start()
        If My.Settings.access_token.Length > 0 Then
            access_token = My.Settings.access_token
            user_id = My.Settings.user_id
            'LongPoll()
        Else
            'WebBrowser1.Navigate("https://oauth.vk.com/authorize?client_id=3558930&scope=offline,messages,status&display=wap&response_type=token")
        End If
    End Sub

    Sub Timer1_Tick()
        Dim processList() As Process


    End Sub

    Private Async Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        Dim temp = txtStatusNew.Text
        CType(sender, Button).IsEnabled = False
        ProgressBar1.Visibility = Windows.Visibility.Visible
        Dim a = Await VKPost("status.set", "text=" & temp)
        If a.ToString = "1" Then
            txtStatus.Text = temp
            pppStatus.IsOpen = False
            pppStatus.IsOpen = True
        End If
        ProgressBar1.Visibility = Windows.Visibility.Hidden
        CType(sender, Button).IsEnabled = True
    End Sub

    Private Sub imgAvatar_MouseLeftButtonDown_1(sender As Object, e As MouseButtonEventArgs)

    End Sub

    Private Sub imgAvatar_MouseEnter(sender As Object, e As MouseEventArgs) Handles imgAvatar.MouseEnter
        pppStatus.IsOpen = False
        pppStatus.IsOpen = True
    End Sub


    Private Async Sub imgAvatar_Loaded_1(sender As Object, e As RoutedEventArgs)
        txtStatus.Text = (Await VKPost("status.get"))("text").ToString
    End Sub
End Class
